<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: register.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "maincore.php";
require_once THEMES."templates/header.php";
include LOCALE.LOCALESET."register.php";
include LOCALE.LOCALESET."user_fields.php";


$avloserid=$_GET['avloserid'];

//Oppkobling mot databasen. Opkoblingsinfo ligger i config.php
$db = mysql_connect($GLOBALS['db_host'], $GLOBALS['db_user'], $GLOBALS['db_password']);
mysql_select_db($GLOBALS['db_name'], $db); 
//--------------------------------------------------------------------------------------------
//Her begynner koden for å hente ut persondata
//Lagrer spørringen som en string i variablen $query
$query=" SELECT * FROM avloser, postkatalog 
	WHERE avloserid=".$avloserid." 
	AND avloser.postnr = postkatalog.postnr"; 	
//Henter ut all info fra avloser og postkat tabellene og lagrer info fra DB i variablen $result
$result=mysql_query($query);
//Teller antall rader i variablen $result og lagrer antallet i variablen $num					
$num=mysql_numrows($result);					

// Setter telleren $i til 0
$i=0;

//While løkken går gjennom gjennom variablen result så lenge telleren $i er mindre en antall rader $num											
while ($i < $num) {
	$fornavn/*Variablen data skal lagres i*/=mysql_result($result/*Variablen data skal hentes ut fra*/,$i/*Nummer på raden data skal hentes fra*/,"fornavn"/*navn på felt i DB*/);
	$etternavn=mysql_result($result,$i,"etternavn");
	$adresse=mysql_result($result,$i,"adresse");
	$postnr=mysql_result($result,$i,"postnr");
	$telefon=mysql_result($result,$i,"telefon");
	$mobil=mysql_result($result,$i,"mobil");
	$epost=mysql_result($result,$i,"epost");
	$aktiv=mysql_result($result,$i,"aktiv");
	$poststed=mysql_result($result,$i,"poststed");
	$type=mysql_result($result,$i,"type");
	++$i; //teller økes med 1
}
//Skriver ut tabellen som persondata skal stå i 
echo "
	<br></br> 
	<table class='capmain' border='0' cellpadding='0' align='center'>
		<tr>
			<th><font style='text-transform: capitalize;'>Informasjon om:&nbsp; $fornavn  $etternavn </font></th>
		</tr>
	</table>
	
		<table class='imagetable' border='0' cellpadding='5' tableborder='10' align='center'>
		<tr>	<th><b>Etternavn</b></th>	<td>$etternavn</td>		</tr>
		<tr>	<th><b>Fornavn</b></th>		<td>$fornavn</td>		</tr>
		<tr>	<th><b>Mobil</b></th>		<td>$mobil</td>			</tr>
		<tr>	<th><b>Adresse</b></th>		<td>$adresse</td>		</tr>
		<tr>	<th><b>Postnr</b></th>		<td>$postnr</td>		</tr>
		<tr>	<th><b>Poststed</b></th>	<td>$poststed</td>		</tr>
		<tr>	<th><b>Telefon</b></th>		<td>$telefon</td>		</tr>
		<tr>	<th><b>Epost</b></th>		<td>$epost</td>			</tr>
		<tr>	<th><b>Aktiv</b></th>		<td>$aktiv</td>			</tr>
		<tr>	<th><b>Type</b></th>		<td>$type</td>			</tr>
		
	
	</table>
	<table class='imagetable' border='0' cellpadding='5' tableborder='10' align='center'>
		<tr>	
			<td align=center><form action='update_profil.php?avloserid=$avloserid' method='post' ><input type='Submit' value='Endre info'>		</form>		</td>
			<td align=center><form action='bekreft_slettavloser.php?avloserid=$avloserid' method='post'><input type='Submit' value='Slett person'>	</form>		</td>
		</tr>
	</table>";
//Her slutter koden for å hente ut persondata		
//--------------------------------------------------------------------------------------------

//Her begynner funksjonen for kontrakt
//--------------------------------------------------------------------------------------------

$query="SELECT * FROM arbeidskontrakt, avloser  
	WHERE avloser.avloserid=$avloserid
	AND avloser.avloserid=arbeidskontrakt.avloserid 
	ORDER BY oppsigelsesdato DESC" ;
$result=mysql_query($query);
$num=mysql_numrows($result);
if ($num>0){ 
echo "<br></br>
	<table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><th><font style='text-transform: capitalize;'>Arbeidskontrakt </font></th></tr></table>
	<table class='imagetable' border='0' cellpadding='5' align='center'>
		<tr>
			<th><b>Ansettelsesdato</b></th>
			<th><b>Oppsigelsesdato</b></th>
			
			
		</tr>";

$i=0;
while ($i < $num) {
	$fra=mysql_result($result,$i,"ansettelsesdato");
	$til=mysql_result($result,$i,"oppsigelsesdato");
	$nyfra = date('d-M-Y', strtotime($fra));
	$nytil = date('d-M-Y', strtotime($til));
	
	
++$i;


echo "
	<tr>
		<td>$nyfra</td>
		<td>$nytil</td>
		
		
	</tr>
	";
} //Slutt på While-løkke
echo "</table>


	<form action='lagrekontrakt.php?avloserid=".$avloserid."&sjekk=nei' method='post'>
	
	
	<table class='imagetable' border='0' cellpadding='5' align='center'>

	<tr>
		<td align='center'><input type='Submit' value='   Legg Til / Slett Kontrakt   '></form></td>
	</tr>
	</table>
	
	
	";




}else{
	
	echo"


	<form action='lagrekontrakt.php?avloserid=".$avloserid."&sjekk=nei' method='post'>
	
	<br></br>
	<table class='imagetable' border='0' cellpadding='5' align='center'>

	<tr>
		<td align='left'><input type='Submit' value='   Legg til ny kontrakt   '></form></td>
	</tr>
	</table>";
	

}//Slutt på IF-Setning
//Her slutter koden for å hente ut data om kontrakt
//--------------------------------------------------------------------------------------------

// Her begynner koden for å hente ut data om skolegang
$query="SELECT skolenavn, fag, aar FROM skolegang, avloser 
	WHERE skolegang.avloserid=avloser.avloserid 
	AND skolegang.avloserid='$avloserid' 
	ORDER by skolegang.aar DESC";
$result=mysql_query($query);
$num=mysql_numrows($result);
if ($num>0){ 
echo "<br></br>
	
	<table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><th><font style='text-transform: capitalize;'>Skole</font></th></tr>
	</table>
	
	<table class='imagetable' border='0' cellpadding='5' align='center'>
		<tr>
			<th><b>Aar</b></th>
			<th><b>Fag</b></th>
			<th><b>Skole</b></th>
		</tr>";

$i=0;
while ($i < $num) {
	$aar=mysql_result($result,$i,"aar");
	$fag=mysql_result($result,$i,"fag");
	$skole=mysql_result($result,$i,"skolenavn");
++$i;


echo "
	<tr>
		<td>$aar</td>
		<td>$fag</td>
		<td>$skole</td>
	</tr>";
} //Slutt på While-løkke
echo "</table>";
echo "

	<form action='lagreskolegang.php?avloserid=".$avloserid."&sjekk=nei' method='post' >
	
	<table class='imagetable' border='0' cellpadding='5' align='center'>

	<tr>
		<td align='center'><input type='Submit' value='   Legg Til / Slett  Skole   '></form></td>
	</tr>
	</table>
	
	
	";
}else{
	
	echo "

	<form action='lagreskolegang.php?avloserid=".$avloserid."&sjekk=nei' method='post' >
	<br></br>
	<table class='imagetable' border='0' cellpadding='5' align='center'>

	<tr>
		<td align='left'><input type='Submit' value='   Legg til ny skole   '></form></td>
	</tr>
	</table>
	
	
	";
	
} //Slutt på IF-Setning
//Her slutter koden for å hente ut data om skolegang
//--------------------------------------------------------------------------------------------
//Her begynner koden for å hente ut data om kurs/sertifikat
$query="SELECT * FROM kurs_sertifikat, avloser  
	WHERE avloser.avloserid=$avloserid
	AND avloser.avloserid=kurs_sertifikat.avloserid 
	ORDER BY aar DESC" ;
$result=mysql_query($query);
$num=mysql_numrows($result);
if ($num>0){ 
echo "<br></br>
	<table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><th><font style='text-transform: capitalize;'>Kurs/Sertifikat</font></th></tr></table>
	<table class='imagetable' border='0' cellpadding='5' align='center'>
		<tr>
			<th><b>Aar</b></th>
			<th><b>Kurs- Sertifikattype</b></th>
			<th><b>Sted</b></th>
		</tr>";

$i=0;
while ($i < $num) {
	$kaar=mysql_result($result,$i,"aar");
	$ktype=mysql_result($result,$i,"kurstype");
	$ksted=mysql_result($result,$i,"kurssted");
++$i;


echo "
	<tr>
		<td>$kaar</td>
		<td>$ktype</td>
		<td>$ksted</td>
	</tr>
	";
} //Slutt på While-løkke
echo "</table>";
echo "

	<form action='lagrekurs.php?avloserid=".$avloserid."&sjekk=nei' method='post'>
	
	
	<table class='imagetable' border='0' cellpadding='5' align='center'>

	<tr>
		<td align='center'><input type='Submit' value='   Legg Til / Slett Kurs   '></form></td>
	</tr>
	</table>
	
	
	";



}else{
	
	echo "

	<form action='lagrekurs.php?avloserid=".$avloserid."&sjekk=nei' method='post'>
	
	<br></br>
	<table class='imagetable' border='0' cellpadding='5' align='center'>

	<tr>
		<td align='left'><input type='Submit' value='   Legg til nytt kurs   '></form></td>
	</tr>
	</table>
	
	
	";
	
} //Slutt på IF-Setning
//Her slutter koden for å hente ut data om kurs/sertifikat
//--------------------------------------------------------------------------------------------

//Her begynner funksjonen for arbeidserfaring
//--------------------------------------------------------------------------------------------

$query="SELECT * FROM arbeidserfaring, avloser  
	WHERE avloser.avloserid=$avloserid
	AND avloser.avloserid=arbeidserfaring.avloserid 
	ORDER BY tildato DESC" ;
$result=mysql_query($query);
$num=mysql_numrows($result);
if ($num>0){ 
echo "<br></br>
	<table class='capmain' border='0' cellpadding='0' align='center'>
	<tr><th><font style='text-transform: capitalize;'>Arbeidserfaring</font></th></tr></table>
	<table class='imagetable' border='0' cellpadding='5' align='center'>
		<tr>
			<th><b>Fra</b></th>
			<th><b>Til</b></th>
			<th><b>Sted</b></th>
			<th><b>Erfaring</b></th>
		</tr>";

$i=0;
while ($i < $num) {
	$fra=mysql_result($result,$i,"fradato");
	$til=mysql_result($result,$i,"tildato");
	$asted=mysql_result($result,$i,"arbeidssted");
	$erfaring=mysql_result($result,$i,"erfaring");
	$nyfra = date('d-M-Y', strtotime($fra));
	$nytil = date('d-M-Y', strtotime($til));
++$i;


echo "
	<tr>
		<td>$nyfra</td>
		<td>$nytil</td>
		<td>$asted</td>
		<td>$erfaring</td>
	</tr>
	";
} //Slutt på While-løkke
echo "</table>";
echo "

	<form action='lagreerfaring.php?avloserid=".$avloserid."&sjekk=nei' method='post'>
	
	
	<table class='imagetable' border='0' cellpadding='5' align='center'>

	<tr>
		<td align='center'><input type='Submit' value='   Legg Til / Slett Erfaring   '></form></td>
	</tr>
	</table>
	
	
	";



}else{
	echo "

	<form action='lagreerfaring.php?avloserid=".$avloserid."&sjekk=nei' method='post'>
	
	<br></br>
	<table class='imagetable' border='0' cellpadding='5' align='center'>

	<tr>
		<td align='left'><input type='Submit' value='   Legg til ny erfaring   '></form></td>
	</tr>
	</table>
	
	
	";
	
} //Slutt på IF-Setning
//Her slutter koden for å hente ut data om kurs/sertifikat
//--------------------------------------------------------------------------------------------
//Her begynner koden for å hente ut data om førerkort
$query=" SELECT * FROM forerkort WHERE avloserid='$avloserid'";
$result=mysql_query($query);
$num=mysql_numrows($result);


$i=0;
while ($i < $num) {
$klasse=mysql_result($result,$i,"klasse");
$utgaar=mysql_result($result,$i,"utgaar");
$oppkjoring_klasse=mysql_result($result,$i,"oppkjoring_klasse");


++$i;


opentable($locale['704']);

echo "<table class='imagetable' border='0' cellpadding='5'>
<tr>
<th><b>F&oslash;rerkort klasse:</b></th><td>$klasse</td>
</tr>
<tr>
<th><b>Utg&aring;r dato:</b></th><td>$utgaar</td>
</tr>
<tr>
<th><b>Oppkj&oslash;rt klasse:</b></th><td>$oppkjoring_klasse</td>
</tr>";



closetable();
}








if ($num!=0){

echo "<form action='forerkort_update_file.php?avloserid=$avloserid' method='post'>

<input type='Submit' value='Oppdater'>
</form><form action='forerkort_delete.php?avloserid=$avloserid' method='post' ><input type='Submit' value='Slett'></form>";

closetable();

}
else{
opentable($locale['704']);

echo "<form action='forerkort.php?avloserid=$avloserid' method='post'>

<input type='Submit' value='Legg til'>
</form>";

closetable();

}


// Her begynner koden for å hente ut data om skolegang
$query="SELECT  egenvurdering_id, egenvurdering.avloserid, sau_foring, sau_sanking, sau_lamming, storfe_foring, storfe_melking, storfe_kalving, gris, fjerfe, traktor, sau_foring_egen, sau_sanking_egen, sau_lamming_egen, storfe_foring_egen, storfe_melking_egen, storfe_kalving_egen, gris_egen, fjerfe_egen, traktor_egen
	FROM egenvurdering, avloser
	WHERE egenvurdering.avloserid = avloser.avloserid
	AND egenvurdering.avloserid =$avloserid";
$result=mysql_query($query);
$num=mysql_numrows($result);




if ($num>0){ 
echo "<br></br>

	<table class='capmain' border='0' cellpadding='0' align='center' width='608px'>
	
	<tr><th>Egenvurdering</th></tr></table>
	<table class='imagetable' table border='0' cellpadding='5' align='center'>

";
$i=0;
while ($i < $num) {
	$sau_foring=mysql_result($result,$i,"sau_foring");
	$sau_sanking=mysql_result($result,$i,"sau_sanking");
	$sau_lamming=mysql_result($result,$i,"sau_lamming");
	$storfe_foring=mysql_result($result,$i,"storfe_foring");
	$storfe_melking=mysql_result($result,$i,"storfe_melking");
	$storfe_kalving=mysql_result($result,$i,"storfe_kalving");
	$gris=mysql_result($result,$i,"gris");
	$fjerfe=mysql_result($result,$i,"fjerfe");
	$traktor=mysql_result($result,$i,"traktor");
	$sau_foring_egen=mysql_result($result,$i,"sau_foring_egen");
	$sau_sanking_egen=mysql_result($result,$i,"sau_sanking_egen");
	$sau_lamming_egen=mysql_result($result,$i,"sau_lamming_egen");
	$storfe_foring_egen=mysql_result($result,$i,"storfe_foring_egen");
	$storfe_melking_egen=mysql_result($result,$i,"storfe_melking_egen");
	$storfe_kalving_egen=mysql_result($result,$i,"storfe_kalving_egen");
	$gris_egen=mysql_result($result,$i,"gris_egen");
	$fjerfe_egen=mysql_result($result,$i,"fjerfe_egen");
	$traktor_egen=mysql_result($result,$i,"traktor_egen");
	$sid=mysql_result($result,$i,"egenvurdering_id");
++$i;

echo "

	<form action='updateform_egenvurdering.php?sid=".$sid."&avloserid=".$avloserid."&slett=ja&sjekk=nei' method='post'>
	<tr>
		<th></th>
		<th>Null</th>
		<th>Litt</th>
		<th>Ok</th>
		<th>Bra</th>
		<th></th>
		<th>Nei Takk</th>
		<th>Helst Ikke</th>
		<th>Ok</th>
		<th>Ja Takk</th>
		<th>&Oslash;nsker &aring; l&aelig;re mer</th>
	</tr>
	<tr>
		<th>Sau: </th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th>
	</tr>
	<tr>
	<th>Foring </th><td><input type='radio' name='sau_foring' value='Null'>"; if ($_GET['sau_foring']=='Null') echo 														             			"checked=\'checked\'</td>
						<td><input type='radio' name='sau_foring' value='Litt'>"; if ($_GET['sau_foring']=='Litt') echo 														             			"checked=\'checked\'</td>
						<td><input type='radio' name='sau_foring' value='Ok'>"; if ($_GET['sau_foring']=='Ok') echo 														             			"checked=\'checked\'</td>
						<td><input type='radio' name='sau_foring' value='Bra'>"; if ($_GET['sau_foring']=='Bra') echo 														             			"checked=\'checked\'</td>
						<th></th>
						<td><input type='radio' name='sau_foring_egen' value='Nei Takk'>"; if ($_GET['sau_foring_egen']=='Nei Takk') echo 														             			"checked=\'checked\'</td>
						<td><input type='radio' name='sau_foring_egen' value='Ok'>"; if ($_GET['sau_foring_egen']=='Ok') echo 														             			"checked=\'checked\'</td>
						<td><input type='radio' name='sau_foring_egen' value='Helst Ikke'>"; if ($_GET['sau_foring_egen']=='Helst Ikke') echo 														             			"checked=\'checked\'</td>
						<td><input type='radio' name='sau_foring_egen' value='Ja Takk'>"; if ($_GET['sau_foring_egen']=='Ja Takk') echo 														             			"checked=\'checked\'</td>
						<td><input type='radio' name='sau_foring_egen' value='&Oslash;nsker &aring; l&aelig;re mer'"; if ($_GET['sau_foring_egen']=='Ønsker å lære mer') echo "checked=\'checked\'></td>
	</tr>
	<tr>";

echo" 		<th>Sanking </th><td><input type='radio' name='sau_sanking' value='Null'>"; if ($_GET['sau_sanking']=='Null') echo 														             			"checked=\'checked\'</td> 
						 <td><input type='radio' name='sau_sanking' value='Litt'=$checklitt></td>
						 <td><input type='radio' name='sau_sanking' value='Ok'=$checkok></td>
						 <td><input type='radio' name='sau_sanking' value='Bra'=$checkbra></td>
						 <th></th>
						 <td><input type='radio' name='sau_sanking_egen' value='Nei Takk'=$checkne></td>
						 <td><input type='radio' name='sau_sanking_egen' value='Ok'=$checkkk></td>
						 <td><input type='radio' name='sau_sanking_egen' value='Helst Ikke=$checkikke'></td>
						 <td><input type='radio' name='sau_sanking_egen' value='Ja Takk'=$checkja></td>
						 <td><input type='radio' name='sau_sanking_egen' value='&Oslash;nsker &aring; l&aelig;re mer'=$checkmer></td>
	</tr>
	<tr>";
	switch($sau_lamming)
{
   case 'null': $checknull = 'checked'; break;
   case 'litt': $checklitt = 'checked'; break;
   case 'ok': $checkok = 'checked'; break;
   case 'bra': $checkbra = 'checked'; break;
   case 'nei takk': $checknei = 'checked'; break;
   case 'helst ikke': $checkikke = 'checked'; break;
   case 'ok': $checkkk = 'checked'; break;
   case 'ja takk': $checkja = 'checked'; break;
   case 'ønsker å lære mere': $checkmer = 'checked'; break;
} 
switch($sau_lamming_egen)
{
   case 'null': $checknull = 'checked'; break;
   case 'litt': $checklitt = 'checked'; break;
   case 'ok': $checkok = 'checked'; break;
   case 'bra': $checkbra = 'checked'; break;
   case 'nei takk': $checknei = 'checked'; break;
   case 'helst ikke': $checkikke = 'checked'; break;
   case 'ok': $checkkk = 'checked'; break;
   case 'ja takk': $checkja = 'checked'; break;
   case 'ønsker å lære mere': $checkmer = 'checked'; break;
} 
echo"		<th>Lamming </th><td><input type='radio' name='sau_lamming' value='Null'=$checknull></td>
						 <td><input type='radio' name='sau_lamming' value='Litt'=$checklitt></td>
						 <td><input type='radio' name='sau_lamming' value='Ok'=$checkok></td>
						 <td><input type='radio' name='sau_lamming' value='Bra'=$checkbra></td>
						 <th></th>
						 <td><input type='radio' name='sau_lamming_egen' value='Nei Takk'=$checknei></td>
						 <td><input type='radio' name='sau_lamming_egen' value='Ok'=$checkkk></td>
						 <td><input type='radio' name='sau_lamming_egen' value='Helst Ikke'=$checkikke></td>
						 <td><input type='radio' name='sau_lamming_egen' value='Ja Takk'=$checkja></td>
						 <td><input type='radio' name='sau_lamming_egen' value='&Oslash;nsker &aring; l&aelig;re mer'=$checkmer></td>
	</tr>
	<tr>
		<th>Storfe:</th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th>
	</tr>
	<tr>";
	switch($storfe_foring)
{
   case 'null': $checknull = 'checked'; break;
   case 'litt': $checklitt = 'checked'; break;
   case 'ok': $checkok = 'checked'; break;
   case 'bra': $checkbra = 'checked'; break;
   case 'nei takk': $checknei = 'checked'; break;
   case 'helst ikke': $checkikke = 'checked'; break;
   case 'ok': $checkkk = 'checked'; break;
   case 'ja takk': $checkja = 'checked'; break;
   case 'ønsker å lære mere': $checkmer = 'checked'; break;
} 
switch($storfe_foring_egen)
{
   case 'null': $checknull = 'checked'; break;
   case 'litt': $checklitt = 'checked'; break;
   case 'ok': $checkok = 'checked'; break;
   case 'bra': $checkbra = 'checked'; break;
   case 'nei takk': $checknei = 'checked'; break;
   case 'helst ikke': $checkikke = 'checked'; break;
   case 'ok': $checkkk = 'checked'; break;
   case 'ja takk': $checkja = 'checked'; break;
   case 'ønsker å lære mere': $checkmer = 'checked'; break;
} 
echo"		<th>Foring </th><td><input type='radio' name='storfe_foring' value='Null'=$checknull></td>
						<td><input type='radio' name='storfe_foring' value='Litt'=$checklitt></td>
						<td><input type='radio' name='storfe_foring' value='Ok=$checkok'></td>
						<td><input type='radio' name='storfe_foring' value='Bra'=$checkbra></td>
						<th></th>
						<td><input type='radio' name='storfe_foring_egen' value='Nei Takk'=$checknei></td>
						<td><input type='radio' name='storfe_foring_egen' value='Ok'=$checkkk></td>
						<td><input type='radio' name='storfe_foring_egen' value='Helst Ikke'=$checkikke></td>
						<td><input type='radio' name='storfe_foring_egen' value='Ja Takk'=$checkja></td>
						<td><input type='radio' name='storfe_foring_egen' value='&Oslash;nsker &aring; l&aelig;re mer'=$checkmer></td>
	</tr>
	<tr>";
switch($storfe_melking)
{
   case 'null': $checknull = 'checked'; break;
   case 'litt': $checklitt = 'checked'; break;
   case 'ok': $checkok = 'checked'; break;
   case 'bra': $checkbra = 'checked'; break;
   case 'nei takk': $checknei = 'checked'; break;
   case 'helst ikke': $checkikke = 'checked'; break;
   case 'ok': $checkkk = 'checked'; break;
   case 'ja takk': $checkja = 'checked'; break;
   case 'ønsker å lære mere': $checkmer = 'checked'; break;
} 	
switch($storfe_melking_egen)
{
   case 'null': $checknull = 'checked'; break;
   case 'litt': $checklitt = 'checked'; break;
   case 'ok': $checkok = 'checked'; break;
   case 'bra': $checkbra = 'checked'; break;
   case 'nei takk': $checknei = 'checked'; break;
   case 'helst ikke': $checkikke = 'checked'; break;
   case 'ok': $checkkk = 'checked'; break;
   case 'ja takk': $checkja = 'checked'; break;
   case 'ønsker å lære mere': $checkmer = 'checked'; break;
} 
echo"		<th>Melking </th><td><input type='radio' name='storfe_melking' value='Null'=$checknull></td>
						 <td><input type='radio' name='storfe_melking' value='Litt'=$checklitt></td>
						 <td><input type='radio' name='storfe_melking' value='Ok'=$checkok></td>
						 <td><input type='radio' name='storfe_melking' value='Bra'=$checkbra></td>
						 <th></th>
						 <td><input type='radio' name='storfe_melking_egen' value='Nei Takk'=$checknei></td>
						 <td><input type='radio' name='storfe_melking_egen' value='Ok'=$checkkk></td>
						 <td><input type='radio' name='storfe_melking_egen' value='Helst Ikke'=$checkikke></td>
						 <td><input type='radio' name='storfe_melking_egen' value='Ja Takk'=$checkja></td>
						 <td><input type='radio' name='storfe_melking_egen' value='&Oslash;nsker &aring; l&aelig;re mer'=$checkmer></td>>
	</tr>
	<tr>";
	switch($storfe_kalving)
{
   case 'null': $checknull = 'checked'; break;
   case 'litt': $checklitt = 'checked'; break;
   case 'ok': $checkok = 'checked'; break;
   case 'bra': $checkbra = 'checked'; break;
   case 'nei takk': $checknei = 'checked'; break;
   case 'helst ikke': $checkikke = 'checked'; break;
   case 'ok': $checkkk = 'checked'; break;
   case 'ja takk': $checkja = 'checked'; break;
   case 'ønsker å lære mere': $checkmer = 'checked'; break;
} 
switch($storfe_kalving_egen)
{
   case 'null': $checknull = 'checked'; break;
   case 'litt': $checklitt = 'checked'; break;
   case 'ok': $checkok = 'checked'; break;
   case 'bra': $checkbra = 'checked'; break;
   case 'nei takk': $checknei = 'checked'; break;
   case 'helst ikke': $checkikke = 'checked'; break;
   case 'ok': $checkkk = 'checked'; break;
   case 'ja takk': $checkja = 'checked'; break;
   case 'ønsker å lære mere': $checkmer = 'checked'; break;
} 
echo"		<th>Kalving </th><td><input type='radio' name='storfe_kalving' value='Null'=$checknull></td>
						 <td><input type='radio' name='storfe_kalving' value='Litt'=$checklitt></td>
						 <td><input type='radio' name='storfe_kalving' value='Ok'=$checkok></td>
						 <td><input type='radio' name='storfe_kalving' value='Bra'=$checkbra></td>
						 <th></th>
						 <td><input type='radio' name='storfe_kalving_egen' value='Nei Takk'=$checknei></td>
						 <td><input type='radio' name='storfe_kalving_egen' value='Ok'=$checkkk></td>
						 <td><input type='radio' name='storfe_kalving_egen' value='Helst Ikke'=$checkikke></td>
						 <td><input type='radio' name='storfe_kalving_egen' value='Ja Takk'=$checkja></td>
						 <td><input type='radio' name='storfe_kalving_egen' value='&Oslash;nsker &aring; l&aelig;re mer'=$checkmer></td>
	</tr>
	<tr>";
	switch($gris)
{
   case 'null': $checknull = 'checked'; break;
   case 'litt': $checklitt = 'checked'; break;
   case 'ok': $checkok = 'checked'; break;
   case 'bra': $checkbra = 'checked'; break;
   case 'nei takk': $checknei = 'checked'; break;
   case 'helst ikke': $checkikke = 'checked'; break;
   case 'ok': $checkkk = 'checked'; break;
   case 'ja takk': $checkja = 'checked'; break;
   case 'ønsker å lære mere': $checkmer = 'checked'; break;
}
switch($gris_egen)
{
   case 'null': $checknull = 'checked'; break;
   case 'litt': $checklitt = 'checked'; break;
   case 'ok': $checkok = 'checked'; break;
   case 'bra': $checkbra = 'checked'; break;
   case 'nei takk': $checknei = 'checked'; break;
   case 'helst ikke': $checkikke = 'checked'; break;
   case 'ok': $checkkk = 'checked'; break;
   case 'ja takk': $checkja = 'checked'; break;
   case 'ønsker å lære mere': $checkmer = 'checked'; break;
}
echo"		 <th>Gris:</th><td><input type='radio' name='gris' value='Null'=$checknull></td>
					   <td><input type='radio' name='gris' value='Litt'=$checklitt></td>
					   <td><input type='radio' name='gris' value='Ok'=$checkok></td>
					   <td><input type='radio' name='gris' value='Bra'=$checkbra></td>
					   <th></th>
					   <td><input type='radio' name='gris_egen' value='Nei Takk'=$checknei></td>
					   <td><input type='radio' name='gris_egen' value='Ok'=$checkkk></td>
					   <td><input type='radio' name='gris_egen' value='Helst Ikke'=$checkikke></td>
					   <td><input type='radio' name='gris_egen' value='Ja Takk'=$checktakk></td>
					   <td><input type='radio' name='gris_egen' value='&Oslash;nsker &aring; l&aelig;re mer'=$checkmer></td>
	</tr>
	<tr>";
	 switch($fjerfe)
{
   case 'null': $checknull = 'checked'; break;
   case 'litt': $checklitt = 'checked'; break;
   case 'ok': $checkok = 'checked'; break;
   case 'bra': $checkbra = 'checked'; break;
   case 'nei takk': $checknei = 'checked'; break;
   case 'helst ikke': $checkikke = 'checked'; break;
   case 'ok': $checkkk = 'checked'; break;
   case 'ja takk': $checkja = 'checked'; break;
   case 'ønsker å lære mere': $checkmer = 'checked'; break;
} 
switch($fjerfe_egen)
{
   case 'null': $checknull = 'checked'; break;
   case 'litt': $checklitt = 'checked'; break;
   case 'ok': $checkok = 'checked'; break;
   case 'bra': $checkbra = 'checked'; break;
   case 'nei takk': $checknei = 'checked'; break;
   case 'helst ikke': $checkikke = 'checked'; break;
   case 'ok': $checkkk = 'checked'; break;
   case 'ja takk': $checkja = 'checked'; break;
   case 'ønsker å lære mere': $checkmer = 'checked'; break;
} 
echo"   <th>Fj&aelig;rfe:</th><td><input type='radio' name='fjerfe' value='Null'=$checknull></td>
						 <td><input type='radio' name='fjerfe' value='Litt'=$checklitt></td>
						 <td><input type='radio' name='fjerfe' value='Ok'=$checkok></td>
						 <td><input type='radio' name='fjerfe' value='Bra'=$checkbra></td>
						 <th></th>
						 <td><input type='radio' name='fjerfe_egen' value='Nei Takk'=$checknei></td>
						 <td><input type='radio' name='fjerfe_egen' value='Ok'=$checkkk></td>
						 <td><input type='radio' name='fjerfe_egen' value='Helst Ikke'=$checkikke></td>
						 <td><input type='radio' name='fjerfe_egen' value='Ja Takk'=$checkja></td>
						 <td><input type='radio' name='fjerfe_egen' value='&Oslash;nsker &aring; l&aelig;re mer'=$checkmer></td>
	</tr>
	<tr>";
	switch($traktor)
{
   case 'null': $checknull = 'checked'; break;
   case 'litt': $checklitt = 'checked'; break;
   case 'ok': $checkok = 'checked'; break;
   case 'bra': $checkbra = 'checked'; break;
   case 'nei takk': $checknei = 'checked'; break;
   case 'helst ikke': $checkikke = 'checked'; break;
   case 'ok': $checkkk = 'checked'; break;
   case 'ja takk': $checkja = 'checked'; break;
   case 'ønsker å lære mere': $checkmer = 'checked'; break;
} 
switch($traktor_egen)
{
   case 'null': $checknull = 'checked'; break;
   case 'litt': $checklitt = 'checked'; break;
   case 'ok': $checkok = 'checked'; break;
   case 'bra': $checkbra = 'checked'; break;
   case 'nei takk': $checknei = 'checked'; break;
   case 'helst ikke': $checkikke = 'checked'; break;
   case 'ok': $checkkk = 'checked'; break;
   case 'ja takk': $checkja = 'checked'; break;
   case 'ønsker å lære mere': $checkmer = 'checked'; break;
} 
echo"		<th>Traktor:</th><td><input type='radio' name='traktor' value='Null'=$checknull></td>
						 <td><input type='radio' name='traktor' value='Litt'=$checklitt></td>
						 <td><input type='radio' name='traktor' value='Ok'=$checkok></td>
						 <td><input type='radio' name='traktor' value='Bra'=$checkbra></td>
						 <th></th>
						 <td><input type='radio' name='traktor_egen' value='Nei Takk'=$checknei></td>
						 <td><input type='radio' name='traktor_egen' value='Ok'=$checkkk></td>
						 <td><input type='radio' name='traktor_egen' value='Helst Ikke'=$checkikke></td>
						 <td><input type='radio' name='traktor_egen' value='Ja Takk'=$checkja></td>
						 <td><input type='radio' name='traktor_egen' value='&Oslash;nsker &aring; l&aelig;re mer'=$checkmer></td>
	</tr>
";
} //Slutt på While-løkke

echo "</table>";


echo "

	<form action='updateform_egenvurdering.php?avloserid=".$avloserid."&sjekk=nei' method='post' >
	
	<table class='imagetable' border='0' cellpadding='5' align='center'>

	<tr>
		<td align='center'><input type='Submit' value='   Endre / Oppdater   '></form></td>
	</tr>
	</table>
	
	
	";
}else{
	
	echo "

	<form action='lagreegenvurdering.php?avloserid=".$avloserid."&sjekk=nei' method='post' >
	<br></br>
	<table class='imagetable' border='0' cellpadding='5' align='center'>

	<tr>
		<td align='left'><input type='Submit' value='   Fyll ut egenvurdering   '></form></td>
	</tr>
	</table>
	
	
	";
	
} //Slutt på IF-Setning
//Her slutter koden for å hente ut data om skolegang
//--------------------------------------------------------------------------------------------
//Her begynner funksjonen for opplasting av dokumenter
//--------------------------------------------------------------------------------------------

     $query = "select image_id, filename, filnavn from images WHERE images.avloserid=$avloserid";
    $result = mysql_query($query, $db);
 
    $images = array();
 
    while ($row = mysql_fetch_array($result)) {
        $id = $row['image_id'];
        $images[$id] = $row['filnavn'];
    }

echo "
<html>
    <table class='capmain' border='0' cellpadding='0' align='center' '>
	<tr><th>Dokumenter</th></tr></table>
    <body>
 
            <ul>";
                 if (count($images) == 0) { 
echo"         <li><b>Ingen dokumenter</b></li>";
                		 } else foreach ($images as $id => $filnavn) { 
echo"    	 <li>
                       <b> <a href='view.php?id=$id' target='_BLANK'> $filnavn </a> </b>
                    </li>";
                 } 
echo"         </ul>
	
	<br></br>

	<table class='imagetable' border='0' cellpadding='5' align='center'>

	<tr>
	
	<form action='dokument.php?avloserid=".$avloserid."' method='post'>
	
	<td align='center'><input type='Submit' value='   Last Opp / Slett Dokument   '></form></td>
	</tr>
	</table>
    </body>
</html>
"; //Slutt på IF-Setning
//Her slutter koden for å hente ut dokumenter
//----------------------------------------------------------------------------------------




require_once THEMES."templates/footer.php";

?>